package com.ship.system.api.factory;

import com.ship.system.api.RemoteMessageSendService;
import com.ship.system.api.domain.SysMessageSend;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 消息管理服务降级处理
 * 
 * @author zhangyh
 */
@Component
public class RemoteMessageFallbackFactory implements FallbackFactory<RemoteMessageSendService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteMessageFallbackFactory.class);

    @Override
    public RemoteMessageSendService create(Throwable throwable)
    {
        log.error("系统消息服务调用失败:{}", throwable.getMessage());
        return new RemoteMessageSendService()
        {
            @Override
            public void messageSend(SysMessageSend messageSend) {

            }

            @Override
            public void messageSendBatch(List<SysMessageSend> messageSend) {

            }
        };
    }
}
